<?php


namespace app\single\model;


use think\exception\DbException;
use think\Model;

class RoleTaskLastUploadLogModel extends Model
{
    protected $table = "l_table_player_task_last_upload";

    protected $schema = [
        'id' => 'int',
        'player_id' => 'int',
        'main_task_id' => 'int',
        'daily_task_id' => 'int',
        'micro_task_id' => 'int',
        'friend_task_id' => 'int',
        "vip_task_id" => 'int',
    ];


    public function updateLogData($playerId, $data)
    {
        $res_count = $this->where("player_id", $playerId)->count();
        if ($res_count === 0) {
            $this->insert($data);
        } else {
            $this->where("player_id", $playerId)->update($data);
        }
    }


    /**
     * @param $playerId
     * @return array|array[]|\array[][]|\array[][][]
     * @throws DbException
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function get_player_data($playerId)
    {
        return $this->where("player_id", $playerId)->select()->toArray();
    }

}